<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                    template="./AdminTemplate.xhtml">
        <ui:define name="Title">
            <title>Vehicle</title>
        </ui:define>
        <ui:define name="content">
            <h:form>
                <div id="content" style="width: 700px ;margin: 10px auto">

                    <p:dataTable  id="datatable" value="#{adminVihicleBean.listVihicle}" var="vehicle"  widgetVar="vehicleTable"
                                  emptyMessage="No cars found with given criteria">
                        <f:facet name="header">
                            <p:outputPanel>
                                <h:outputText value="Search all fields:" />
                                <p:inputText id="globalFilter" onkeyup="vehicleTable.filter()" style="width:150px" />
                            </p:outputPanel>
                            <h:commandButton value="Add Vehicle" action="#{addVehicle.addVehicle}"/>
                        </f:facet>
                        <p:column  headerText="Image" footerText="Image" style="width: 110px">
                            <p:graphicImage value="/ImgCar/#{vehicle.image}" style="width: 110px; height: 70px" />
                        </p:column>
                        <p:column id="nameColumn" filterBy="#{vehicle.vehilceName}" headerText="Name" footerText="Name">
                            <h:outputText value="#{vehicle.vehilceName}" />
                        </p:column>
                        <p:column id="priceColumn" filterBy="#{vehicle.price}" headerText="Price" footerText="Price">
                            <h:outputText value="#{vehicle.price}" />
                        </p:column>
                        <p:column id="editColumn" headerText="Edit" footerText="Edit">
                            <p:commandLink  id="btnedit" value="Edit price" />
                            <p:overlayPanel id="carPanel" for="btnedit" hideEffect="fade" dynamic="true">
                                <h:inputText value="#{adminVihicleBean.pricenew}" style="width: 150px" />
                                <h:commandButton value="Update" action="#{adminVihicleBean.editPriceVehicle(vehicle)}"/>
                                <br/>
                                <h:commandButton style="float: right;margin-right: 3px" value="Close" action="#{adminVihicleBean.closeEditPrice}"/>
                            </p:overlayPanel>
                        </p:column>

                    </p:dataTable>

                </div>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

